# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>

_hkgname=alsa-mixer
pkgname=haskell-${_hkgname}
pkgver=0.3.0
pkgrel=73
pkgdesc='Bindings to the ALSA simple mixer API'
url='https://hackage.haskell.org/package/alsa-mixer'
license=('BSD')
arch=('loong64' 'x86_64')
depends=('ghc-libs' 'glibc' 'gmp' 'alsa-lib' 'haskell-base' 'haskell-unix'
         'haskell-alsa-core' 'haskell-extensible-exceptions')
makedepends=('ghc' 'c2hs')
source=(https://github.com/ttuegel/alsa-mixer/archive/${pkgver}/${pkgname}-${pkgver}.tar.gz)
sha256sums=('afc9aba478e37af03f38707e0bddc8a2c2f51ddc27a93bd8b81a277077f72ccf')
sha512sums=('3977808321218a7694a59ff294664b2a9ae6e735844040adf89bf63ef75f025aada555fde6c79cbe19f4ca9c7546005de5a2b132c2fd6deef2c1a38ae555fe5f')

build() {
  cd ${_hkgname}-${pkgver}
    runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
        --prefix=/usr --docdir=/usr/share/doc/$pkgname \
        --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid --ghc-option=-fllvm \
        --ghc-option=-optl-Wl\,-z\,relro\,-z\,now \
        --ghc-option='-pie'
    runhaskell Setup build $MAKEFLAGS
    runhaskell Setup haddock
    runhaskell Setup register --gen-script
    runhaskell Setup unregister --gen-script
    sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh
    sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
}

check() {
  cd ${_hkgname}-${pkgver}
  runhaskell Setup test --show-details=direct
}

package() {
  cd ${_hkgname}-${pkgver}
  install -Dm 744 register.sh "${pkgdir}/usr/share/haskell/register/${pkgname}.sh"
  install -Dm 744 unregister.sh "${pkgdir}/usr/share/haskell/unregister/${pkgname}.sh"
  install -dm 755 "${pkgdir}/usr/share/doc/ghc/html/libraries"
  runhaskell Setup copy --destdir="$pkgdir"

  install -Dm 644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"
  ln -s /usr/share/doc/${pkgname}/html "${pkgdir}/usr/share/doc/ghc/html/libraries/${_hkgname}"
}

# vim: ts=2 sw=2 et:
